package snail.validators;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

public class EditUserValidator implements Validator {

    public boolean supports(Class aClass) {
     //   return User.class.equals(aClass);
        return true;
    }

    public void validate(Object obj, Errors errors) {
        //fields cannot be empty
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "field.required", "Required field");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "field.required", "Required field");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "address", "field.required", "Required field");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "postAddress", "field.required", "Required field");

    }
}
